﻿using System;
using System.Collections.Generic;
using System.Configuration.Provider;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace durable.xml.ConfigProvider
{
    public abstract partial class Provider : ProviderBase
    {
        
        public abstract void Insert(dynamic p);
        /// <summary>
        /// 修改项目
        /// </summary>
        /// <param name="p"></param>
        public abstract void Update(dynamic p);
        /// <summary>
        /// 删除项目
        /// </summary>
        /// <param name="code"></param>
        public abstract void Delete(string code);
        public abstract dynamic Entity(string code);
        public abstract List<dynamic> Fill();
        public abstract List<dynamic> Fill(string name, string value);
    }
    public class Collection : ProviderCollection
    {
        /// <summary>
        /// Gets a provider by its name.
        /// </summary>
        public new Provider this[string name]
        {
            get { return (Provider)base[name]; }
        }

        /// <summary>
        /// Add a provider to the collection.
        /// </summary>
        public override void Add(ProviderBase provider)
        {
            if (provider == null)
                throw new ArgumentNullException("provider");

            if (!(provider is Provider))
                throw new ArgumentException
                    ("Invalid provider type", "provider");

            base.Add(provider);
        }
    }
}


